package cn.pconline.autoclub.entity;

import java.util.Date;

import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

import cn.pconline.autoclub.util.AppUtils;

/**
 * @author zhouruxuan
 * @date 2015年3月27日 下午5:00:48
 */
@Entity(tableName = "ac_subject_info")
public class Subject {
	
    @Id
    @Column(name = "subject_id")
    private long subjectId;
    @Column(name = "title")
    private String title;
    @Column(name = "introduction")
    private String introduction;
    @Column(name = "status")
    private int status;
    @Column(name = "pv_count")
    private long pvCount;
    @Column(name = "reply_count")
    private long replyCount;
    @Column(name = "create_by")
    private long createBy;
    @Column(name = "create_at")
    private Date createAt;
    @Column(name = "update_by")
    private long updateBy;
    @Column(name = "update_at")
    private Date updateAt;
    @Column(name = "logo")
    private String logo;
    @Column(name = "cover")
    private String cover;
    /**
     * 是否包含图片
     */
    @Column(name="is_pic")
    private int isPic;
    @Transient
	private String createName;
    public static final int STATUS_DELETE = -1;
    public static final int STATUS_NORMAL = 1;
    
	/**置顶   value ：1**/
	public static final int TOP_YES = 1;
	/**不是置顶   value ：0**/
	public static final int TOP_NO = 0;
	/**全部数据   value ：0**/
	public static final int ALL_DATA = 2;
	
	/**默认封面图**/
	public static final String DEFAULT_COVER= "http://www1.pcauto.com.cn/20150323/hotTopic/img/defHD.jpg";
	/**默认封面图(小图)**/
	public static final String DEFAULT_COVER_SMALL = "http://www1.pcauto.com.cn/20150323/hotTopic/img/defHD.jpg";
	/**默认LOGO**/
	public static final String DEFAULT_LOGO = "http://www1.pcauto.com.cn/20150323/hotTopic/img/defLogo.jpg";
	/**话题导语最大长度**/
	public static final int DEFAULT_MAX_INTRODUCTION_LENGTH = 500;
        /**
         * 包含图片
         */
	public static final int HAS_PIC = 1;
        /**
         * 不包含图片
         */
        public static final int NOT_PIC = 1;
        /** 导语最大上传图片数量 **/
        public static final int MAX_PHOTO_SIZE = 4;
	public long getSubjectId() {
		return subjectId;
	}
	public void setSubjectId(long subjectId) {
		this.subjectId = subjectId;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getIntroduction() {
		return introduction;
	}
	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public long getPvCount() {
		return pvCount;
	}
	public void setPvCount(long pvCount) {
		this.pvCount = pvCount;
	}
	public long getReplyCount() {
		return replyCount;
	}
	public void setReplyCount(long replyCount) {
		this.replyCount = replyCount;
	}

	public long getCreateBy() {
    	return createBy;
    }
	public void setCreateBy( long createBy ) {
    	this.createBy = createBy;
    }
	public Date getCreateAt() {
		return createAt;
	}
	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}
	public long getUpdateBy() {
		return updateBy;
	}
	public void setUpdateBy(long updateBy) {
		this.updateBy = updateBy;
	}
	public Date getUpdateAt() {
		return updateAt;
	}
	public void setUpdateAt(Date updateAt) {
		this.updateAt = updateAt;
	}
	public String getLogo() {
		return logo;
	}
	public void setLogo(String logo) {
		this.logo = logo;
	}
	public String getCover() {
		return cover;
	}
	public void setCover(String cover) {
		this.cover = cover;
	}

        public int getIsPic() {
            return isPic;
        }

        public void setIsPic(int isPic) {
            this.isPic = isPic;
        }
	
	public final String getDefaultCover(){
		return DEFAULT_COVER;
	}
	
	public final String getDefaultSmallCover(){
		return DEFAULT_COVER_SMALL;
	}
	
	public final String getDefaultLogo(){
		return DEFAULT_LOGO;
	}
	public String getCreateName() {
		return createName;
	}
	public void setCreateName(String createName) {
		this.createName = createName;
	}
	
    public String getCoverUrl297x75() {
        return AppUtils.converImg(cover,"_990x250","_297x75");
    }
    public boolean hasPic(){
        return isPic == HAS_PIC;
    }
    public String getShowIntroduction(){
    	String showIntroduction =introduction;
    	showIntroduction = showIntroduction.replaceAll("<br>", "")
    	.replaceAll("</br>", "")
    	.replaceAll("<BR>", "")
    	.replaceAll("</BR>", "")
    	.replaceAll("&gt;", ">" )
    	.replaceAll("&lt;", "<" );
    	return showIntroduction;
    }
    
}
